﻿@model Webs.Models.RegisterModel          
@Content.Script("jquery.validate.min.js", Url)
@Content.Script("jquery.validate.unobtrusive.min.js", Url)
<div id="dErrMsg" class="ui-state-error ui-corner-all" style="margin-top: 5px; padding: 5px;
    font-size: .9em;">
    <p style="vertical-align: top; margin: 0; padding: 0;">
        <span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
        <strong>@ViewBag.ErrMsg
            <span id="msg">asdasd</span></strong>
    </p>
    <div style="margin-left: 23px;">@Html.ValidationSummary(false, "Please correct the errors and try again:")</div>
</div>
<script type="text/javascript">
    $("#dErrMsg").hide();
</script>
@if (ViewBag.SuccMsg != null)
{
    <div id="dSuccMsg" class="ui-state-highlight ui-corner-all" style="margin-top: 5px;
        padding: 5px; font-size: .9em;">
        <p style="vertical-align: top; margin: 0; padding: 0;">
            <span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
            <strong>@ViewBag.SuccMsg</strong>
        </p>
    </div>
}
<div class="editor-label">
    @AccountRes.AccountString.UserName @Html.ValidationMessageFor(m => m.UserName)
</div>
<div class="editor-field">
    @Html.TextBoxFor(m => m.UserName, new { Class = "editor-field-col" })
</div>
<div class="editor-label">
    @AccountRes.AccountString.FirstName @Html.ValidationMessageFor(m => m.FirstName)
</div>
<div class="editor-field">
    @Html.TextBoxFor(m => m.FirstName, new { Class = "editor-field-col" })
</div>
<div class="editor-label">
    @AccountRes.AccountString.LastName @Html.ValidationMessageFor(m => m.LastName)
</div>
<div class="editor-field">
    @Html.TextBoxFor(m => m.LastName, new { Class = "editor-field-col" })
</div>
<div class="editor-label">
    Email @Html.ValidationMessageFor(m => m.Email)
</div>
<div class="editor-field">
    @Html.TextBoxFor(m => m.Email, new { Class = "editor-field-col" })
</div>
<div class="editor-label">
    @AccountRes.AccountString.Password @Html.ValidationMessageFor(m => m.Password)
</div>
<div class="editor-field">
    @Html.PasswordFor(m => m.Password, new { Class = "editor-field-col" })
</div>
<div class="editor-label">
    @Html.RadioButtonFor(m => m.Role, @AccountRes.AccountString.Memmber, new { @checked = "checked" })
    @AccountRes.AccountString.Memmber
    @Html.RadioButtonFor(m => m.Role, @AccountRes.AccountString.Accountant) @AccountRes.AccountString.Accountant
    @Html.RadioButtonFor(m => m.Role, @AccountRes.AccountString.Administrator) @AccountRes.AccountString.Administrator
</div>
<div class="editor-label">
    <input type="submit" id="btnSubmit" value="@AccountRes.AccountString.Register" class="btn" />
</div>
<script type="text/javascript">
    $(document).ready(function () {

        $("#btnSubmit").click(function () {            
            $("#msg").html("");
            var msg = "";
            $("#UserName").removeClass("input-validation-error");

            if ($("#UserName").val() == "") {
                msg += "@AccountRes.AccountString.UserName" + " " + "@SharedRes.SharedString.IsRequired" + "<br />";
                $("#UserName").addClass("input-validation-error");
            }
            if ($("#FirstName").val() == "") {
                msg += "@AccountRes.AccountString.FirstName" + " " + "@SharedRes.SharedString.IsRequired" + "<br />";
                $("#FirstName").addClass("input-validation-error");
            }
            if ($("#LastName").val() == "") {
                msg += "@AccountRes.AccountString.LastName" + " " + "@SharedRes.SharedString.IsRequired" + "<br />";
                $("#LastName").addClass("input-validation-error");
            }
            if ($("#Email").val() == "") {
                msg += "Email " + "@SharedRes.SharedString.IsRequired" + "<br />";
                $("#Email").addClass("input-validation-error");
            }
            if ($("#Password").val() == "") {
                msg += "@AccountRes.AccountString.Password" + " " + "@SharedRes.SharedString.IsRequired";
                $("#Password").addClass("input-validation-error");
            }

            if (msg != "") {
                $("#msg").html(msg);
                $("#dErrMsg").show();
                return false;
            }

            $("#msg").html('');
            $("#dErrMsg").hide();
            return true;
        });
    });
</script>
